import Vue from 'vue'
import App from './App.vue'
import router from './router'

Vue.config.productionTip = false

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

import {Message} from "element-ui";

import 'font-awesome/css/font-awesome.min.css'

router.beforeEach((to,from,next) =>{
    if (to.path == '/') {
        document.body.style.background = '#2d3a4b';
        next();
    }else{
        let user = window.sessionStorage.getItem('loginer');
        if (user == null) {
            Message.warning('请先登录');
            next('/');
        }else{
            document.body.style.background = '#fff';
            next();
        }
    }
})

// 注册api插件
import {getRequest} from "./utils/api";
import {postRequest} from "./utils/api";
import {postKeyValueRequest} from "./utils/api";
import {putRequest} from "./utils/api";
import {deleteRequest} from "./utils/api";
Vue.prototype.$getRequest = getRequest;
Vue.prototype.$postRequest = postRequest;
Vue.prototype.$postKeyValueRequest = postKeyValueRequest;
Vue.prototype.$putRequest = putRequest;
Vue.prototype.$deleteRequest = deleteRequest;


new Vue({
    router,
    render: h => h(App)
}).$mount('#app')